local packer = require("packer")
packer.startup({
    function(use)
        -- Packer 可以管理自己本身
        use 'wbthomason/packer.nvim'
        --------------------- colorschemes --------------------
        -- tokyonight
        use("folke/tokyonight.nvim")
        -- nvim-tree
        use({ "kyazdani42/nvim-tree.lua", requires = "kyazdani42/nvim-web-devicons" })
        -- bufferline
        use({ "akinsho/bufferline.nvim", requires = { "kyazdani42/nvim-web-devicons", "moll/vim-bbye" } })
        -- lualine
        use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons" } })
        use("arkav/lualine-lsp-progress")
        -- telescope
        use { 'nvim-telescope/telescope.nvim', requires = { "nvim-lua/plenary.nvim" } }
        -- telescope extensions
        use "LinArcX/telescope-env.nvim"
        -- dashboard-nvim
        use("glepnir/dashboard-nvim")
        -- project
        use("ahmedkhalf/project.nvim")
        -- treesitter
        use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
        --------------------- LSP --------------------
        -- lspconfig
        use({ "neovim/nvim-lspconfig", "williamboman/nvim-lsp-installer" })
        -- 补全引擎
        use("hrsh7th/nvim-cmp")
        -- snippet 引擎
        use("hrsh7th/vim-vsnip")
        -- 补全源
        use("hrsh7th/cmp-vsnip")
        use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
        use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
        use("hrsh7th/cmp-path") -- { name = 'path' }
        use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
        -- 常见编程语言代码段
        use("rafamadriz/friendly-snippets")
        -- ui
        use("onsails/lspkind-nvim")
        use("tami5/lspsaga.nvim")
        -- indent-blankline
        use("lukas-reineke/indent-blankline.nvim")
        -- nvim-autopairs 自动括号
        use("windwp/nvim-autopairs")
        -- Comment
        use("numToStr/Comment.nvim")
        -------------------------------------------------------
        -- 你的插件列表...
        -- markdown
        use("godlygeek/tabular")
        use("plasticboy/vim-markdown") -- 语法
        use("mzlogin/vim-markdown-toc") -- 目录
        use("suan/vim-instant-markdown") -- 预览
        -- only work on linux/mac and needs nodejs
        -- sudo add-apt-repository ppa:chris-lea/node.js
        -- sudo apt-get update
        -- sudo apt-get install nodejs
        -- sudo npm -g install instant-markdown-d
        use("vimwiki/vimwiki")
        -- git 插件
        use("zivyangll/git-blame.vim")
        -- ranger 插件
        use("kevinhwang91/rnvimr")
        -- 多光标插件
        use("mg979/vim-visual-multi")
        -- 颜色显示
        use("norcalli/nvim-colorizer.lua")
        -- vim 中文文档
        use("yianwillis/vimcdoc")
    end,
    config = {
        display = {
            open_fn = function()
                return require("packer.util").float({ border = "single" })
            end,
        },
        -- 并发数限制
        max_jobs = 16,
        -- 自定义源
        git = {
            default_url_format = "https://github.91chi.fun/https://github.com/%s"
            -- default_url_format = "https://hub.fastgit.xyz/%s",
            -- default_url_format = "https://mirror.ghproxy.com/https://github.com/%s",
            -- default_url_format = "https://gitcode.net/mirrors/%s",
            -- default_url_format = "https://gitclone.com/github.com/%s",
        },
    },
})
-- 每次保存 plugins.lua 自动安装插件
pcall(
    vim.cmd,
    [[
    augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerSync
    augroup end
  ]]
)
